package com.ahuzdw.com;

/**
 * Author: Zhang Dongwei
 * Date: 2021/12/16 16:26
 */
public class test1 {
    public static void main(String[] args) {
        String[] str = {"flower", "flow", "flight"};
        int l = str.length;
        int minl = 999;
        String minstr = "";
        String res = "";
        for(int i=0;i<l;i++) {
            if (str[i].length()<minl){
                minl = str[i].length();
                minstr = str[i];
            }
        }
        for(int j=minl;j>=0;j--){
            for(int k=0;k<l;k++){
                System.out.println(str[k]);
                System.out.println(str[k].substring(0, j));
                System.out.println(minstr.substring(0,j));
                if(str[k].substring(0,j).equals(minstr.substring(0,j))){
                    res = minstr.substring(0,j);
                    break;
                }
            }
        }
        System.out.println(res);
    }
}
